package DUI_Lie;

import java.util.Arrays;

//队列的链式储存 头节点即使出栈，尾节点进栈
class one {
    static int head = 0;
    static int rear = 0;
    static int DEFAULT = 5;
    static int[] arr = new int[DEFAULT];

    void isFull() {
        if (rear == DEFAULT) {
            int[] tmp = Arrays.copyOf(arr, 2 * DEFAULT);
            arr = tmp;
            DEFAULT *= 2;
        }
    }

    public void push(int val) {
        isFull();
        arr[rear++] = val;
    }

    public void pop() {
        if (head < rear) {
            head++;
        } else {
            System.out.println("空了");
        }
    }

    public int getCount() {
        return rear - head;
    }
}
public class dulie_lianshi {
    public static void main(String[] args) {
        one h = new one();
        for (int i = 0; i < 5; i++) {
            h.push(i);
        }
        System.out.println(h.getCount());
        for (int i = 0; i < 6; i++) {
            h.pop();
        }
        System.out.println(h.getCount());
    }
}
